package 力扣日常刷题.木22一月.第09天0117;

/**
 * @author 帅小伙
 * @date 2022/1/17
 * @description
 */
public class Demo05动态规划简单买卖股票 {


    public int maxProfit(int[] prices) {
        int ans = 0;
        int min = prices[0];

        for (int i = 1; i < prices.length; i++) {
            ans = Math.max(ans,prices[i] - min);
            if(min > prices[i]) min = prices[i];
        }
        return ans;
    }
}
